<?php
if ( 'GET' != $_SERVER['REQUEST_METHOD'] ) {
	header('Allow: POST');
	header('HTTP/1.1 405 Method Not Allowed');
	header('Content-Type: text/xml');
	echo "<?xml version='1.0' encoding='UTF-8'?>";
	echo "<root>";	
	echo "<total>0</total>";	
	echo "<data>";	
	echo "</data>"; 
	echo "</root>";
	exit;
}
header("Content-type:text/html;charset=utf-8");
/** Sets up the WordPress Environment. */
require( dirname(__FILE__) . '/../../../wp-load.php' ); // 此 comments-ajax.php 位于主题数据夹,所以位置已不同

$first=intval($_REQUEST["first"]);
$last=intval($_REQUEST["last"]);

$firstlim=($first<=1)?0:($first-1);
$lastlim=($last<1)?0:$last;
$args = array(
					'post_type'=>'post',
					'category_name'=>'photo',
					'posts_per_page'=>$lastlim,
					'offset'=>$firstlim,
					'order'=>'DESC',
					'orderby'=>'date' ,
		);
		$wp_query = new WP_Query();
		$wp_query->query($args) ;
		$found_posts=$wp_query->found_posts ;
echo "<?xml version='1.0' encoding='UTF-8'?>";
echo "<root>";	
echo "<total>$found_posts</total>";		
		if($wp_query->have_posts()):	while ( $wp_query->have_posts() ) : $wp_query->the_post();
          $single_post_id=get_the_ID();
		  $attach_id = get_post_thumbnail_id(); 
		  $attach_img=wp_get_attachment_image_src( $attach_id,'full');          
		  $works_title=get_the_title();
		  $imgpath=$attach_img[0];
 echo "<data>";	
		echo "<image>$imgpath</image>";
		echo "<title>$works_title</title>";
 echo "</data>"; 
		   			
					
 endwhile;	
 endif;
 echo "</root>";
 wp_reset_query();?>